bitkeeper revision 1.245 (3ec92fdez1HafjDKzTvVNtSF_Pa4_g)
authorakw27@boulderdash.cl.cam.ac.uk <akw27@boulderdash.cl.cam.ac.uk>
Mon, 19 May 2003 19:26:22 +0000 (19:26 +0000)
committerakw27@boulderdash.cl.cam.ac.uk <akw27@boulderdash.cl.cam.ac.uk>
Mon, 19 May 2003 19:26:22 +0000 (19:26 +0000)
net_headers.h:
  new file
kernel.c:
  remove in-file net header declarations, put them in net_headers.h

.rootkeys
xen/common/kernel.c
xen/include/xeno/net_headers.h [new file with mode: 0644]

index 5094916c1f2af73e8b01c1af09ffce106e47a221..de42d5d43743b8fad6b1f5d437b98d1025f1299d 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 3ddb79c1gs2VbLbQlw0dcDUXYIepDA xen/include/xeno/mm.h
 3ddb79c13p9iHn1XAp0IS1qvj4yDsg xen/include/xeno/module.h
 3ddb79c1ieLZfGSFwfvvSQ2NK1BMSg xen/include/xeno/multiboot.h
+3ec92e46saEJq7v1vgEJD3HZSufSBg xen/include/xeno/net_headers.h
 3ddb79c0CLfAlJLg1ohdPD-Jjn-jxg xen/include/xeno/netdevice.h
 3e4540ccaugeWGdOuphJKj6WFw1jkw xen/include/xeno/notifier.h
 3ddb79c2Fg44_PBPVxHSC0gTOMq4Ow xen/include/xeno/pci.h
index 3c92324ca15b8a0504ddba1f15461050e8572d80..5e1e2fc194e7f677f09e1ec399bc585609fac1db 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/if_ether.h>
 #include <asm/domain_page.h>
 #include <xeno/console.h>
+#include <xeno/net_headers.h>
 
 static int xpos, ypos;
 static volatile unsigned char *video;
@@ -467,42 +468,6 @@ unsigned short compute_cksum(unsigned short *buf, int count)
 
 extern int netif_rx(struct sk_buff *); 
 
-typedef struct my_udphdr {
-    __u16 source;
-    __u16 dest;
-    __u16 len;
-    __u16 check;
-} my_udphdr_t; 
-
-
-typedef struct my_iphdr {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-    __u8    ihl:4,
-       version:4;
-#elif defined (__BIG_ENDIAN_BITFIELD)
-    __u8    version:4,
-       ihl:4;
-#else
-#error  "Please fix <asm/byteorder.h>"
-#endif
-    __u8    tos;
-    __u16   tot_len;
-    __u16   id;
-    __u16   frag_off;
-    __u8    ttl;
-    __u8    protocol;
-    __u16   check;
-    __u32   saddr;
-    __u32   daddr;
-} my_iphdr_t; 
-
-
-typedef struct my_ethhdr {
-    unsigned char   h_dest[6];         
-    unsigned char   h_source[6];       
-    unsigned short  h_proto;        
-} my_ethhdr_t; 
-
 /*
  * Function written by ek247. Exports console output from all domains upwards 
  * to domain0, by stuffing it into a fake network packet.
@@ -510,13 +475,13 @@ typedef struct my_ethhdr {
 int console_export(char *str, int len)
 {
     struct sk_buff *skb;
-    struct my_iphdr *iph = NULL;  
-    struct my_udphdr *udph = NULL; 
-    struct my_ethhdr *ethh = NULL; 
-    int hdr_size = sizeof(struct my_iphdr) + sizeof(struct my_udphdr); 
+    struct iphdr *iph = NULL;  
+    struct udphdr *udph = NULL; 
+    struct ethhdr *ethh = NULL; 
+    int hdr_size = sizeof(struct iphdr) + sizeof(struct udphdr); 
     u8 *skb_data;
 
-    skb = dev_alloc_skb(sizeof(struct my_ethhdr) + 
+    skb = dev_alloc_skb(sizeof(struct ethhdr) + 
                                    hdr_size + len + 20);
     if ( skb == NULL ) return 0;
 
@@ -525,12 +490,12 @@ int console_export(char *str, int len)
     skb_reserve(skb, 2);
 
     /* Get a pointer to each header. */
-    ethh = (struct my_ethhdr *) 
+    ethh = (struct ethhdr *) 
         (skb_data + (skb->data - skb->head));
-    iph  = (struct my_iphdr *)(ethh + 1);
-    udph = (struct my_udphdr *)(iph + 1); 
+    iph  = (struct iphdr *)(ethh + 1);
+    udph = (struct udphdr *)(iph + 1); 
 
-    skb_reserve(skb, sizeof(struct my_ethhdr)); 
+    skb_reserve(skb, sizeof(struct ethhdr)); 
     skb_put(skb, hdr_size + len); 
 
     /* Build IP header. */
@@ -544,12 +509,12 @@ int console_export(char *str, int len)
     iph->saddr   = htonl(0xa9fefeff);  /* 169.254.254.255 */
     iph->tot_len = htons(hdr_size + len); 
     iph->check  = 0;
-    iph->check   = compute_cksum((__u16 *)iph, sizeof(struct my_iphdr)/2); 
+    iph->check   = compute_cksum((__u16 *)iph, sizeof(struct iphdr)/2); 
 
     /* Build UDP header. */
     udph->source = htons(current->domain);
     udph->dest   = htons(666);
-    udph->len    = htons(sizeof(struct my_udphdr) + len);
+    udph->len    = htons(sizeof(struct udphdr) + len);
     udph->check  = 0;
 
     /* Build the UDP payload. */
diff --git a/xen/include/xeno/net_headers.h b/xen/include/xeno/net_headers.h
new file mode 100644 (file)
index 0000000..a90b201
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * net_headers.h
+ *
+ * This is a compilation of various network headers, to facilitate
+ * access in Xen, which is generally quite simple and doesn't need
+ * all the bloat of extra defines and so on.
+ *
+ * Pretty much everything here is pulled from ip.h, tcp.h, and if_eth.h
+ *
+ * Reduced, congealed, and otherwise munged by akw. 
+ * 
+ * Original authors:
+ * 
+ *    Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> (ip.h, tcp.h, udp.h)
+ *
+ *    (if_arp.h):
+ *    Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988
+ *    Portions taken from the KA9Q/NOS (v2.00m PA0GRI) source.
+ *    Ross Biro, <bir7@leland.Stanford.Edu>
+ *    Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
+ *    Florian La Roche,
+ *    Jonathan Layes <layes@loran.com>
+ *    Arnaldo Carvalho de Melo <acme@conectiva.com.br> ARPHRD_HWX25
+ *
+ * Original legalese:
+ *
+ *    This program is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU General Public License
+ *    as published by the Free Software Foundation; either version
+ *    2 of the License, or (at your option) any later version.
+ */
+
+#ifndef __NET_HEADERS_H__
+#define __NET_HEADERS_H__
+
+#include <xeno/types.h>
+#include <asm/byteorder.h>
+#include <xeno/if_ether.h> 
+
+/* from ip.h */
+
+struct iphdr {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+    __u8    ihl:4,
+        version:4;
+#elif defined (__BIG_ENDIAN_BITFIELD)
+    __u8    version:4,
+        ihl:4;
+#else
+#error  "Please fix <asm/byteorder.h>"
+#endif
+    __u8    tos;
+    __u16   tot_len;
+    __u16   id;
+    __u16   frag_off;
+    __u8    ttl;
+    __u8    protocol;
+    __u16   check;
+    __u32   saddr;
+    __u32   daddr;
+    /*The options start here. */
+};
+
+/* from tcp.h */
+
+struct tcphdr {
+    __u16   source;
+    __u16   dest;
+    __u32   seq;
+    __u32   ack_seq;
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+    __u16   res1:4,
+        doff:4,
+        fin:1,
+        syn:1,
+        rst:1,
+        psh:1,
+        ack:1,
+        urg:1,
+        ece:1,
+        cwr:1;
+#elif defined(__BIG_ENDIAN_BITFIELD)
+    __u16   doff:4,
+        res1:4,
+        cwr:1,
+        ece:1,
+        urg:1,
+        ack:1,
+        psh:1,
+        rst:1,
+        syn:1,
+        fin:1;
+#else
+#error  "Adjust your <asm/byteorder.h> defines"
+#endif
+    __u16   window;
+    __u16   check;
+    __u16   urg_ptr;
+};
+
+/* From udp.h */
+
+struct udphdr {
+    __u16   source;
+    __u16   dest;
+    __u16   len;
+    __u16   check;
+};
+
+/* from if_arp.h */
+
+struct arphdr
+{
+    __u16   ar_hrd;                      /* format of hardware address    */
+    __u16   ar_pro;                      /* format of protocol address    */
+    __u8    ar_hln;                      /* length of hardware address    */
+    __u8    ar_pln;                      /* length of protocol address    */
+    __u16   ar_op;                       /* ARP opcode (command)          */
+
+    /* This next bit is variable sized, and as coded only allows ETH-IPv4 */
+    __u8    ar_sha[ETH_ALEN];            /* sender hardware address       */
+    __u32   ar_sip;                      /* sender IP address             */
+    __u8    ar_tha[ETH_ALEN];            /* target hardware address       */
+    __u32   ar_tip;                      /* target IP address             */
+};
+
+
+#endif /* __NET_HEADERS_H__ */